package com.itheima.cncom;

import java.io.IOException;
import java.net.*;

public class Client {
    public static void main(String[] args) throws IOException {
        //创建发送基站
        DatagramSocket datagramSocket = new DatagramSocket();
        //指定发送IP地址
        InetAddress byName = InetAddress.getByName("127.0.0.1");
        //输入发送的内容，并转化成字节数组
        byte[] bytes = "好好学习，天天向上".getBytes();
        //指定端口号
        int port = 10100;
        //将数据打包
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length,byName,port);
        //放入基站中
        datagramSocket.send(dp);
        //关闭流
        datagramSocket.close();
    }
}
